import { BroadCastCall } from "../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../Framework/MQ/MessageBlock";
import { SPetStatusUpdate } from "../../../../Message/Game/SPetStatusUpdate";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { EPetStatus } from "../../../../Message/Game/EPetStatus";
//class PetStatusUpdateCommand
    
    export  class PetStatusUpdateCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            super.call(arg1);
            var loc1=arg1.messageBase as SPetStatusUpdate;
            _cache.pet.updatePetStatus(loc1);
            Dispatcher.dispatchEvent(new DataEvent(EventName.PetStatusUpdate, loc1));
            if (loc1.status.value() != EPetStatus._EPetRest) 
            {
                if (loc1.status.value() == EPetStatus._EPetEquip) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetDeath));
                }
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetRestSuccess));
            }
            return;
        }
    }
